<?php
namespace app\web\controller;

use app\model\Theme; 

class Shangjia extends Base
{
    public function Shangjia()
    {
global $_G, $_P;
//load_func('tpl');
$system = $_G['system'];
$themeid = intval($_P['themeid']);
if($themeid <= 0){
	$themeid = Theme::getDefaultThemenew();
}
$config = 	Theme::getConfig($themeid);
		$do = 'shangjia';
		$action=intval($_P['action']);
		$pageNumber = max(1, intval($_P['page']));
		$pageSize = 20;
		if ($action==4){

			$sql = "SELECT y.* FROM " . tablename ( t_shangjiagroup ) . " as y
					ORDER BY y.displayorder  LIMIT ".($pageNumber - 1) * $pageSize.','.$pageSize;
			$list = db_select ( $sql );
			$total = db_fetchcolumn('SELECT COUNT(*) FROM ' .tablename(t_shangjiagroup)." as y ");

		}else{
			if ($action==2){
				$tiaojian =" and y.state=0 ";
			}elseif ($action==3){
				$tiaojian =" and y.state=3 ";
			}else{
				$tiaojian =" and y.state=1 ";
			}

			$sql = "SELECT y.* FROM " . tablename ( t_shangjia ) . " as y
					WHERE 1=1 {$tiaojian} ORDER BY y.displayorder  LIMIT ".($pageNumber - 1) * $pageSize.','.$pageSize;
			$list = db_select ( $sql );
			$total = db_fetchcolumn('SELECT COUNT(*) FROM ' .tablename(t_shangjia)." as y WHERE 1=1 {$tiaojian}");
		}

		$pager = pagination($total, $pageNumber, $pageSize);
		$return_clicent = get_defined_vars();
return view('/shangjia', $return_clicent);
}
}